# -*- encoding:utf-8 -*-
import requests
from requests.auth import HTTPBasicAuth
import constant.constant_define as constant_define
__author__ = 'shudong.msd'


headers = {
    'Connection':'keep-alive',
    'Cache-Control': 'max-age=0',
    'Accept-Encoding':'gzip, deflate, sdch',
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
    'User-Agent': constant_define.user_agent,
    'Accept-Language': 'zh-CN,zh;q=0.8,en;q=0.6',
    'Host':'xueqiu.com',
}

cookie_str = ''

def init_cookie():
    global cookie_str
    global headers
    if cookie_str == '':
        req = requests.post('https://xueqiu.com/user/login', headers=headers,auth=HTTPBasicAuth('18845076037', 'tiger111'))
        for item in req.cookies.iteritems():
            cookie_str += item[0]+'='+item[1]+';'

    return cookie_str
